import type { Camera } from "../core/Camera";
import { GNode } from "../core/GNode";
import { Input, KeyCode } from "../core/input/Input";


export class Rect extends GNode{

    width: number;
    height: number;

    constructor(width: number, height: number) {
        super();
        this.width = width;
        this.height = height;
    }


    update(deltaTime: number): void {
        if(Input.isKeyDown(KeyCode.KeyA)){
            this.position.x -= 10;
        }
        if(Input.isKeyDown(KeyCode.KeyW)){
            this.position.y += 10;
        }
        if(Input.isKeyDown(KeyCode.KeyD)){
            this.position.x += 10;
        }
        if(Input.isKeyDown(KeyCode.KeyS)){
            this.position.y -= 10;
        }
    }

    render(context: CanvasRenderingContext2D, camera: Camera): void {
        context.strokeRect(this.position.x,this.position.y, this.width, this.height);
    }
}